<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.laputa.service.model.MainFrameData"%>
<%@ page import="com.laputa.model.City"%>
<%@ page import="com.laputa.model.Ground"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<%
		MainFrameData data = (MainFrameData) session.getAttribute("userData");
		MainFrameData friendData = (MainFrameData) pageContext.findAttribute("friendData");
		
		if (pageContext.findAttribute("userID") == null) 
			request.setAttribute("userID", data.getId());
		
		request.setAttribute("userName", data.getName());
		
		City city = data.getCity();
		String thisName = data.getName();
		Long money = data.getMoney();
		if (friendData != null) {
			thisName = friendData.getName();
			city = friendData.getCity();
			money = friendData.getMoney();
		}
	 %>
	
	<head>
		<base href="<%=basePath%>">

		<title>Welcome, ${userName}</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="default/default.css">

	</head>
	
	<body>
		<table id="banner" width="100%">
			<tr>
				<td align="center">
					<font size="30" color="blue"> Welcome to This Game!</font>
				</td>
			</tr>
		</table>
		
		userID = ${userID}<br/>
		getID() = <%=data.getId().toString() %> <br/>
		<logic:equal name="userID" value="<%=data.getId().toString()%>">
			欢迎，<%=thisName %>。
		</logic:equal>
		<logic:notEqual name="userID" value="<%=data.getId().toString()%>">
			这是<%=thisName%>的页面。
		</logic:notEqual>
		<br/>
		
		money = <%=money%> 
		<br/>

		${thisName}所拥有的土地是（一共<%=city.getGroundID().size()%>块)：<br/>
		<c:forEach var="i" items="<%=city.getGroundID()%>">
			<form method="post" action="showGround.do">
				<input type="hidden" name="groundID" value="<%=(Long)pageContext.findAttribute("i")%>"/>
				<input type="submit" name="show" value="土地${i}"/><br/>
			</form>
			<br/>
		</c:forEach>

		<logic:equal name="userID" value="<%=data.getId().toString()%>">
			<form method="post" action="friendList.do">
				<input type="submit" name="showList" value="显示好友列表"/>
			</form>
		</logic:equal>
		<logic:notEqual name="userID" value="<%=data.getId().toString()%>">
			<form method="post" action="login.do">
	 			<input type="submit" name="home" value="返回" />
	 		</form>
		</logic:notEqual>
	</body>
</html>
